<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:o="http://omnifaces.org/ui"
      xmlns:of="http://omnifaces.org/functions"
      xmlns:jsf="http://xmlns.jcp.org/jsf">
    <h:head>
    </h:head>

    <h:body>
        <ui:composition template="/dataverse_template.xhtml">
            <ui:param name="pageTitle" value="#{empty DataversePage.dataverse.name ? bundle.new : DataversePage.dataverse.name}"/>
            <ui:param name="dataverse" value="#{DataversePage.dataverse}"/>
            <ui:define name="meta_header">
            <meta name="description" content="#{MarkupChecker:stripAllTags(DataversePage.dataverse.description)}"/>
            </ui:define>
            <ui:define name="body">
                <f:metadata>
                    <f:viewParam name="id" value="#{DataversePage.dataverse.id}"/>
                    <f:viewParam name="alias" value="#{DataversePage.dataverse.alias}"/>
                    <f:viewParam name="ownerId" value="#{DataversePage.ownerId}"/>
                    <f:viewParam name="editMode" value="#{DataversePage.editMode}"/>
                    <f:viewAction action="#{dataverseSession.updateLocaleInViewRoot}"/>
                    <f:viewAction action="#{DataversePage.init}"/>
                    <f:viewAction action="#{dataverseHeaderFragment.initBreadcrumbs(DataversePage.dataverse)}"/>
                    <f:viewParam name="alias" value="#{SearchIncludeFragment.dataverseAlias}"/>
                    <f:viewParam name="q" value="#{SearchIncludeFragment.query}"/>
                    <f:viewParam name="types" value="#{SearchIncludeFragment.selectedTypesString}"/>
                    <f:viewParam name="fq1" value="#{SearchIncludeFragment.fq1}"/>
                    <f:viewParam name="fq0" value="#{SearchIncludeFragment.fq0}"/>
                    <f:viewParam name="fq2" value="#{SearchIncludeFragment.fq2}"/>
                    <f:viewParam name="fq3" value="#{SearchIncludeFragment.fq3}"/>
                    <f:viewParam name="fq4" value="#{SearchIncludeFragment.fq4}"/>
                    <f:viewParam name="fq5" value="#{SearchIncludeFragment.fq5}"/>
                    <f:viewParam name="fq6" value="#{SearchIncludeFragment.fq6}"/>
                    <f:viewParam name="fq7" value="#{SearchIncludeFragment.fq7}"/>
                    <f:viewParam name="fq8" value="#{SearchIncludeFragment.fq8}"/>
                    <f:viewParam name="fq9" value="#{SearchIncludeFragment.fq9}"/>
                    <f:viewParam name="sort" value="#{SearchIncludeFragment.sortField}"/>
                    <f:viewParam name="order" value="#{SearchIncludeFragment.sortOrder}"/>
                    <f:viewParam name="page" value="#{SearchIncludeFragment.page}"/>
                    <f:viewParam name="debug" value="#{SearchIncludeFragment.debug}"/>
                    <f:viewParam name="adjustFacetName" value="#{SearchIncludeFragment.adjustFacetName}"/>
                    <f:viewParam name="adjustFacetNumber" value="#{SearchIncludeFragment.adjustFacetNumber}"/>
                    <f:viewAction action="#{SearchIncludeFragment.search()}" />
                </f:metadata>

                <h:form id="dataverseForm">
                    <!-- Edit Mode -->
                    <ui:fragment rendered="#{DataversePage.editMode == 'INFO' or DataversePage.editMode == 'CREATE'}">
                        <p:focus context="dataverseForm"/>
                        <!-- Sample Block -->
                        <!-- Name Panel -->
                        <!-- Edit Info Panel -->
                        <div class="row">
                            <div class="col-xs-6 form-group form-col-container">
                                <label class="col-sm-3 control-label" for="name">
                                    #{bundle.dataverse} <span class="glyphicon glyphicon-asterisk text-danger" title="#{bundle.requiredField}"/>
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataverse.title']}"></span>
                                </label>
                                <div class="col-sm-9 form-col-container">
                                    <p:inputText id="name" tabindex="1" styleClass="form-control" value="#{DataversePage.dataverse.name}"/>
                                </div>
                            </div>
                            <div class="col-xs-6 form-group form-col-container">
                                <label class="col-sm-3 control-label" for="affiliation">
                                    #{bundle.affiliation}
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataverse.affiliation.title']}"></span>
                                </label>
                                <div class="col-sm-9 form-col-container">
                                    <p:inputText id="affiliation" tabindex="2" styleClass="form-control" value="#{DataversePage.dataverse.affiliation}"/>
                                    <p:message for="affiliation" display="text"/>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-6 form-group form-col-container">
                                <div class="form-group clearfix">
                                    <label class="col-sm-3 control-label" for="dataverseCategory">
                                        #{bundle['dataverse.category']} <span class="glyphicon glyphicon-asterisk text-danger" title="#{bundle.requiredField}"/>
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                              data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataverse.category.title']}"></span>
                                    </label>
                                    <div class="col-sm-9 form-col-container">
                                        <h:selectOneMenu id="dataverseCategory" tabindex="5" styleClass="form-control" value="#{DataversePage.dataverse.dataverseType}">
                                            <f:selectItem id="dvSelect" itemLabel="#{bundle['dataverse.type.selectTab.top']}" itemValue="" />
                                            <f:selectItem id="dvDepartment" itemLabel="#{bundle['dataverse.type.selectTab.department']}" itemValue="DEPARTMENT" />
                                            <f:selectItem id="dvJournals" itemLabel="#{bundle['dataverse.type.selectTab.journals']}" itemValue="JOURNALS" />
                                            <f:selectItem id="dvLab" itemLabel="#{bundle['dataverse.type.selectTab.laboratory']}" itemValue="LABORATORY" />
                                            <f:selectItem id="dvOrgInst" itemLabel="#{bundle['dataverse.type.selectTab.organizationsAndInsitutions']}" itemValue="ORGANIZATIONS_INSTITUTIONS" />
                                            <f:selectItem id="dvResearch" itemLabel="#{bundle['dataverse.type.selectTab.researchers']}" itemValue="RESEARCHERS" />
                                            <f:selectItem id="dvResearchGrp" itemLabel="#{bundle['dataverse.type.selectTab.researchGroup']}" itemValue="RESEARCH_GROUP" />
                                            <f:selectItem id="dvResearchProj" itemLabel="#{bundle['dataverse.type.selectTab.researchProjects']}" itemValue="RESEARCH_PROJECTS" />
                                            <f:selectItem id="dvTeaching" itemLabel="#{bundle['dataverse.type.selectTab.teachingCourses']}" itemValue="TEACHING_COURSES" />
                                            <f:selectItem id="dvUncategorized" itemLabel="#{bundle['dataverse.type.selectTab.uncategorized']}" itemValue="UNCATEGORIZED" />
                                        </h:selectOneMenu>
                                        <p:message for="dataverseCategory" display="text"/>
                                    </div>
                                </div>
                                <div class="form-group clearfix">
                                    <p:fragment>
                                       <p:autoUpdate />
                                        <label class="col-sm-3 control-label" for="contactEmail">
                                            #{bundle['dataverse.email']} <span class="glyphicon glyphicon-asterisk text-danger" title="#{bundle.requiredField}"/>
                                            <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                  data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataverse.email.title']}"></span>
                                        </label>
                                        <div class="col-sm-9 form-col-container edit-compound-field">
                                            <ui:repeat value="#{DataversePage.dataverse.dataverseContacts}" var="contacts" varStatus="valCount">
                                                <div class="form-group">
                                                    <div class="col-sm-8 form-col-container">
                                                        <p:inputText id="contactEmail" tabindex="7" styleClass="form-control" value="#{contacts.contactEmail}">
                                                            <f:validateBean disabled="#{param['SKIP_VALIDATION']}"/>
                                                        </p:inputText>
                                                        <p:message for="contactEmail" display="text"/>
                                                    </div>
                                                    <!-- Add / Remove buttons -->
                                                    <div class="col-sm-4 form-col-container field-add-delete">
                                                        <p:commandLink styleClass="btn btn-default btn-sm bootstrap-button-tooltip" title="#{bundle.add}"
                                                                         actionListener="#{DataversePage.dataverse.addDataverseContact(valCount.index + 1)}"
                                                                         oncomplete="javascript:bind_bsui_components();">
                                                            <f:param name="SKIP_VALIDATION" value="true"/>
                                                            <h:outputText styleClass="glyphicon glyphicon-plus no-text"/>
                                                        </p:commandLink>
                                                        <p:commandLink styleClass="btn btn-default btn-sm bootstrap-button-tooltip" title="#{bundle.delete}"
                                                                         rendered="#{DataversePage.dataverse.dataverseContacts.size() > 1}"
                                                                         actionListener="#{DataversePage.dataverse.removeDataverseContact(valCount.index)}"
                                                                         oncomplete="javascript:bind_bsui_components();">
                                                            <f:param name="SKIP_VALIDATION" value="true"/>
                                                            <h:outputText styleClass="glyphicon glyphicon-minus no-text"/>
                                                        </p:commandLink>
                                                    </div>
                                                </div>
                                            </ui:repeat>
                                        </div>
                                    </p:fragment>
                                </div>
                            </div>
                            <div class="col-xs-6 form-group form-col-container">
                                <label class="col-sm-3 control-label" for="description">
                                    #{bundle.description}
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataverse.description.title']}"></span>
                                </label>
                                <div class="col-sm-9 form-col-container">
                                    <p class="help-block">
                                        <h:outputFormat value="#{bundle.htmlAllowedMsg}" escape="false">
                                            <f:param value="#{bundle.htmlAllowedTags}"/>
                                        </h:outputFormat>
                                    </p>
                                    <p:inputTextarea id="description" tabindex="6" styleClass="form-control" value="#{DataversePage.dataverse.description}"
                                                    rows="6" cols="50"
                                                    autoResize="false">
                                    </p:inputTextarea>
                                    <p:message for="description" display="text"/>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-6 form-group" jsf:rendered="#{DataversePage.ownerId != null}">
                                <label class="col-sm-3 control-label" for="hostDataverse">
                                    #{bundle.hostDataverse}
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataverse.host.title']}"></span>
                                </label>
                                <div class="col-sm-9 form-col-container">
                                    <p class="form-control-static">#{DataversePage.dataverse.getOwner().name}</p>
                                    <h:inputHidden value="#{DataversePage.ownerId}" id="hostDataverse" />
                                    <ui:remove><!-- removed for beta -->
                                        <p:selectOneMenu id="hostDataverse" tabindex="2" value="#{DataversePage.ownerId}" filter="true" filterMatchMode="startsWith" effect="none">
                                            <f:selectItems value="#{dataverseServiceBean.findAll()}" var="dv" itemLabel="#{dv.name}" itemValue="#{dv.id}"
                                                           itemDisabled="#{dv eq DataversePage.dataverse or dv.owners.contains(DataversePage.dataverse)}" />
                                        </p:selectOneMenu>
                                    </ui:remove>
                                </div>
                            </div>
                            <div class="col-xs-6 form-group form-col-container" style="display: none;">
                                <label class="col-sm-3 control-label" for="identifier">
                                    #{bundle.identifier} <!--<span class="glyphicon glyphicon-asterisk text-danger" title="#{bundle.requiredField}"/>-->
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataverse.identifier.title']}"></span>
                                </label>
                                <div class="col-sm-9 form-col-container">
                                    <div class="input-group">
                                        <p:inputText id="identifier" styleClass="form-control" value="#{DataversePage.dataverse.alias}"/>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <hr class="margin-top-half margin-bottom-half"/>

                        <!-- Metadata Panel -->
                        <p:panel styleClass="panelLayoutBlock"  widgetVar="optionBlock" id="optionBlock">
                            <input id="datasetFieldTypeJson" name="datasetFieldTypeJson" type="hidden" value="#{DataversePage.datasetFieldTypeJson}"/>
                            <p:commandButton id="hiddenRefresh" value="back" style="display:none"
                                             actionListener="#{DataversePage.refresh}"
                                             update="@widgetVar(optionBlock)" />

                            <div class="row">
                                <div class="col-sm-12 form-group">
                                    <label class="col-sm-3 control-label" for="mdbSelect">#{bundle['dataverse.metadataElements']}</label>
                                    <div class="col-sm-9">
                                        <p class="help-block">#{bundle['dataverse.metadataElements.tip']}</p>

                                        <label class="metadata-blocks-default" for="metadataRoot" jsf:rendered="#{DataversePage.dataverse.owner != null}">
                                            <h:selectBooleanCheckbox id="metadataRoot" tabindex="7" styleClass="metadata-blocks-default"
                                                                     value="#{DataversePage.inheritMetadataBlockFromParent}" onclick="updateMetadata(this);">
                                            </h:selectBooleanCheckbox>
                                            <h:outputFormat value="#{bundle['dataverse.metadataElements.from.tip']}">
                                                <f:param value="#{DataversePage.dataverse.metadataRootDataverseName}"/>
                                            </h:outputFormat>
                                        </label>

                                        <p:commandButton value="Direct" id="updateMetadataButton"
                                                         style="display:none"
                                                         update="@widgetVar(optionBlock)"
                                                         process="@this @widgetVar(optionBlock)"
                                                         actionListener="#{DataversePage.editMetadataBlocks(false)}">
                                        </p:commandButton>
                                        <p:commandButton value="Direct" id="resetToInherit"
                                                         style="display:none"
                                                         update="@widgetVar(optionBlock)"
                                                         process="@widgetVar(optionBlock)"
                                                         partialSubmit="true"
                                                         action="#{DataversePage.resetToInherit()}">
                                        </p:commandButton>

                                        <ui:repeat value="#{DataversePage.allMetadataBlocks}" var="mdb">
                                            <div class="checkbox" style="display:none;">
                                                <label for="#{mdb.idString}">
                                                    <input type="checkbox" jsf:itemValue="#{mdb}" id="#{mdb.idString}" jsf:value="#{mdb.selected}"
                                                           name="mdbSelectRequired" disabled="disabled" checked="checked" jsf:rendered="#{mdb.required and !DataversePage.inheritMetadataBlockFromParent}" />
                                                    <input type="checkbox" jsf:itemValue="#{mdb}" id="#{mdb.idString}" jsf:value="#{mdb.selected}"
                                                           name="mdbSelectRequiredInherited" disabled="disabled" jsf:rendered="#{DataversePage.inheritMetadataBlockFromParent}">
                                                        <p:ajax update="@widgetVar(optionBlock)" />
                                                    </input>
                                                    <input type="checkbox" jsf:itemValue="#{mdb}" id="#{mdb.idString}" jsf:value="#{mdb.selected}"
                                                           name="mdbSelectOptional" jsf:rendered="#{!mdb.required and !DataversePage.inheritMetadataBlockFromParent}">
                                                        <p:ajax update="@widgetVar(optionBlock)" />
                                                    </input>

                                                    <h:outputText value="#{mdb.localeDisplayName} #{mdb.required ? bundle['dataverse.field.required']: ''}"
                                                                  styleClass="#{DataversePage.inheritMetadataBlockFromParent ? 'text-muted' : ''}"/>
                                                    <p:commandLink id="showDSFT" style="margin-left:1em;display:none;"
                                                                   update="@widgetVar(optionBlock)"
                                                                   process="@this"
                                                                   rendered="#{!mdb.showDatasetFieldTypes and (mdb.selected or mdb.required) and !DataversePage.openMetadataBlock and !DataversePage.inheritMetadataBlockFromParent}"
                                                                   actionListener="#{DataversePage.showDatasetFieldTypes(mdb.id)}"
                                                                   oncomplete="javascript:bind_bsui_components();">
                                                         <h:outputText value="#{bundle['dataverse.field.set.tip']}" />
                                                     </p:commandLink>
                                                     <p:commandLink id="viewDSFT" style="margin-left:1em;display:none;"
                                                                    update="@widgetVar(optionBlock)"
                                                                    process="@this"
                                                                    rendered="#{!mdb.showDatasetFieldTypes and (!mdb.selected or DataversePage.inheritMetadataBlockFromParent)   and !DataversePage.openMetadataBlock}"
                                                                    actionListener="#{DataversePage.showDatasetFieldTypes(mdb.id, false)}"
                                                                    oncomplete="javascript:bind_bsui_components();">
                                                         <h:outputText value="#{bundle['dataverse.field.set.view']}" />
                                                     </p:commandLink>
                                                </label>
                                            </div>

                                            <div id="metadataFieldOptionsPanel-Block" jsf:rendered="#{mdb.showDatasetFieldTypes}" style="margin-left: 0;">
                                                <div class="panel panel-default">
                                                    <div id="metadataFieldOptionsPanel-Body" class="panel-body">
                                                        <table id="metadataFieldOptions" class="table table-striped">
                                                            <tbody>
                                                                <ui:repeat value="#{mdb.datasetFieldTypes}" var="dsft">
                                                                    <tr>
                                                                        <td>
                                                                            <p:selectBooleanCheckbox rendered="#{!dsft.hasParent}" value="#{dsft.include}" itemLabel="#{dsft.displayName}"
                                                                                                      onchange="scrollPos=document.getElementById('metadataFieldOptionsPanel-Body').scrollTop;"
                                                                                                     disabled="#{DataversePage.editInputLevel == false or (!dsft.hasParent and (dsft.hasRequiredChildren or dsft.required))}">
                                                                                <p:ajax update="@widgetVar(optionBlock)" listener="#{DataversePage.updateInclude(mdb.id, dsft.id)}" onstart="collAllOptions()"/>
                                                                            </p:selectBooleanCheckbox>
                                                                            <div class="checkbox child-field" jsf:rendered="#{dsft.hasParent}">
                                                                                <label>
                                                                                    <h:outputText value="#{dsft.displayName}"/>
                                                                                </label>
                                                                            </div>
                                                                        </td>
                                                                        <td>
                                                                            <p:selectOneRadio value="#{dsft.requiredDV}" disabled ="#{DataversePage.editInputLevel == false}"
                                                                                              rendered="#{!dsft.hasChildren and !((!dsft.hasChildren  and dsft.required) or (dsft.hasChildren and dsft.hasRequiredChildren))}">
                                                                                <f:selectItems value="#{dsft.optionSelectItems}"/>
                                                                            </p:selectOneRadio>
                                                                            <h:inputHidden value="#{dsft.id}"/>
                                                                            <span class="text-muted" jsf:rendered="#{(!dsft.hasChildren and dsft.required) or (dsft.hasChildren and dsft.hasRequiredChildren)}">
                                                                                #{bundle['dataverse.field.requiredByDataverse']}
                                                                            </span>
                                                                        </td>
                                                                    </tr>
                                                                </ui:repeat>
                                                            </tbody>
                                                        </table>
                                                    </div>
                                                </div>
                                                <!--<p:commandLink id="hideDSFT" styleClass="btn btn-default"
                                                               update="@widgetVar(optionBlock)" actionListener="#{DataversePage.hideDatasetFieldTypes(mdb.id)}" 
                                                               oncomplete="javascript:bind_bsui_components();"
                                                               rendered="#{mdb.showDatasetFieldTypes}">
                                                    <h:outputText value="#{bundle.done}" />
                                                </p:commandLink>-->
                                            </div>
                                        </ui:repeat>
                                    </div>
                                </div>
                            </div>
                        </p:panel>
                        <!-- Facets Panel -->
                        <p:panel id="editFacets" styleClass="panelLayoutBlock" widgetVar="editFacets">
                            <div class="row">
                                <div class="col-sm-12 form-group">
                                    <label class="col-sm-3 control-label" for="facetPickListCreate">#{bundle['dataverse.facetPickList.text']}</label>
                                    <div class="col-sm-9">
                                        <p class="help-block">#{bundle['dataverse.facetPickList.tip']}</p>

                                        <label class="metadata-blocks-default" for="facetsRoot" jsf:rendered="#{DataversePage.dataverse.owner != null}">
                                            <h:selectBooleanCheckbox id="facetsRoot" tabindex="8" styleClass="facets-blocks-default"
                                                                     value="#{DataversePage.inheritFacetFromParent}">
                                                <p:ajax update="editFacets" listener="#{DataversePage.toggleFacetRoot}"/>
                                            </h:selectBooleanCheckbox>
                                            <h:outputFormat value="#{bundle['dataverse.facetPickList.facetsFromHost.text']}">
                                                <f:param value="#{DataversePage.dataverse.facetRootDataverseName}"/>
                                            </h:outputFormat>
                                        </label>

                                        <p:pickList id="facetPickListCreate" value="#{DataversePage.facets}" var="facet" converter="facetConverter"
                                                    itemLabel="#{facet.displayName}" itemValue="#{facet}"
                                                    disabled="#{!DataversePage.dataverse.facetRoot and DataversePage.dataverse.owner != null}"
                                                    style="margin-top:1em;">
                                            <f:facet name="sourceCaption">
                                                <p:selectOneMenu styleClass="facet-category-default"
                                                                 disabled="#{!DataversePage.dataverse.facetRoot and DataversePage.dataverse.owner != null}"
                                                                 value="#{DataversePage.facetMetadataBlockId}">
                                                    <f:selectItem itemLabel="#{bundle['dataverse.facetPickList.metadataBlockList.all']}" itemValue=""/>
                                                    <f:selectItems value="#{DataversePage.allMetadataBlocks}" var="mdb" itemLabel="#{mdb.localeDisplayName}" itemValue="#{mdb.id}" />
                                                    <p:ajax process="editFacets" update="editFacets" listener="#{DataversePage.changeFacetsMetadataBlock}"/>
                                                </p:selectOneMenu>
                                            </f:facet>
                                            <f:facet name="targetCaption">#{bundle['dataverse.selected']}</f:facet>
                                            <p:ajax event="transfer" listener="#{DataversePage.onFacetTransfer}" update="editFacets" />
                                        </p:pickList>
                                    </div>
                                </div>
                            </div>
                        </p:panel>
                    </ui:fragment>
                    <!-- END Edit Mode -->
                    <!-- View Mode / Description Panel -->
                    <ui:fragment rendered="#{empty DataversePage.editMode}">
                        <div id="actionButtonBlock" class="button-block clearfix" jsf:rendered="#{!widgetWrapper.widgetView}">
                            <!-- Edit/Publish Button Group -->
                            <div class="btn-group pull-right" jsf:rendered="#{dataverseSession.user.authenticated and
                                                     (permissionsWrapper.canIssueUpdateDataverseCommand(DataversePage.dataverse)
                                                     or permissionsWrapper.canIssuePublishDataverseCommand(DataversePage.dataverse))}">
                                    <!-- Publish Button -->
                                    <ui:fragment rendered="#{permissionsWrapper.canIssuePublishDataverseCommand(DataversePage.dataverse)}">
                                        <button type="button" class="btn btn-default btn-access" onclick="PF('confirmation').show()"
                                                jsf:rendered="#{!DataversePage.dataverse.released and (empty DataversePage.dataverse.owner or DataversePage.dataverse.owner.released)}">
                                            <span class="glyphicon glyphicon-globe"/> #{bundle['dataverse.publish.btn']}
                                        </button>
                                        <button type="button" class="btn btn-default btn-access" onclick="PF('mayNotRelease').show()"
                                                jsf:rendered="#{!DataversePage.dataverse.released and (!empty DataversePage.dataverse.owner and !DataversePage.dataverse.owner.released)}">
                                            <span class="glyphicon glyphicon-globe"/> #{bundle['dataverse.publish.btn']}
                                        </button>
                                    </ui:fragment>
                                    <!-- END: Publish Button -->
                                    <div class="btn-group" jsf:rendered="#{dataverseSession.user.superuser and (SearchIncludeFragment.mode == 'search' or DataversePage.dataverse.owner != null)}">
                                        <button type="button" class="btn btn-default btn-access dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                                            <span class="glyphicon glyphicon-link"/> #{bundle['link']} <span class="caret"></span>
                                        </button>
                                        <ul class="dropdown-menu pull-right text-left" role="menu">
                                            <li class="#{DataversePage.dataverse.owner != null ? '' : 'disabled'}">
                                                <p:commandLink action="#{DataversePage.setupLinkingPopup('link')}"
                                                               oncomplete="PF('linkDataverseForm').show()"
                                                               update=":linkDataverseForm"
                                                               disabled="#{DataversePage.dataverse.owner == null}">
                                                    #{bundle['dataverse.link']}
                                                </p:commandLink>
                                            </li>
                                            <!--<li class="#{SearchIncludeFragment.mode == 'search' ? '' : 'disabled'}">
                                                <p:commandLink action="#{DataversePage.setupLinkingPopup('savedSearch')}"
                                                               oncomplete="PF('linkDataverseForm').show()"
                                                               update=":linkDataverseForm"
                                                               disabled="#{SearchIncludeFragment.mode != 'search'}">
                                                    #{bundle['dataverse.savedsearch.link']}
                                                </p:commandLink>
                                            </li>-->
                                        </ul>
                                    </div>
                                    <!-- Edit Button -->
                                    <div class="btn-group" jsf:rendered="#{permissionsWrapper.canIssueUpdateDataverseCommand(DataversePage.dataverse)}">
                                        <button type="button" class="btn btn-default btn-access dropdown-toggle" data-toggle="dropdown">
                                            <span class="glyphicon glyphicon-pencil"/> #{bundle['dataverse.edit']} <span class="caret"></span>
                                        </button>
                                        <ul class="dropdown-menu pull-right text-left" role="menu">
                                            <li>
                                                <div id="dataverse-info-dropdown">
                                                    <div class="dataverse-info-logo-icon">
                                                        <span class="icon-dataverse text-brand"></span>
                                                    </div>
                                                    <div class="dataverse-info-general">
                                                        <div><h:outputText value="#{DataversePage.dataverse.name}" styleClass="highlightBold"/> <h:outputText value=" (#{DataversePage.dataverse.affiliation})" styleClass="text-muted" rendered="#{!empty DataversePage.dataverse.affiliation}"/></div>
                                                        <div class="text-muted">#{DataversePage.dataverse.alias}</div>
                                                    </div>
                                                </div>
                                            </li>
                                            <li class="divider" role="presentation"></li>
                                            <li>
                                                <p:commandLink id="editInfo" actionListener="#{DataversePage.edit('INFO')}" update="@form,:dataverseForm,:searchResults,:messagePanel" oncomplete="javascript:bind_bsui_components();">
                                                    <h:outputText value="#{bundle['dataverse.option.generalInfo']}" />
                                                </p:commandLink>
                                            </li>
                                            <li>
                                                <h:link outcome="ThemeAndWidgets" id="themeWidgetsOpts">
                                                    <f:param name="id" value="#{DataversePage.dataverse.id}" />
                                                    <h:outputText value="#{bundle['dataverse.option.themeAndWidgets']}" />
                                                </h:link>
                                            </li>
                                            <ui:fragment rendered="#{permissionsWrapper.canManagePermissions(DataversePage.dataverse)}">
                                                <li>
                                                    <h:link id="managePermissions" styleClass="ui-commandlink ui-widget" outcome="permissions-manage">
                                                        <h:outputText value="#{bundle['dataverse.option.permissions']}" />
                                                        <f:param name="id" value="#{DataversePage.dataverse.id}" />
                                                    </h:link>
                                                </li>
                                            </ui:fragment>
                                            <ui:fragment rendered="#{permissionsWrapper.canManagePermissions(DataversePage.dataverse)}">
                                                <li>
                                                    <h:link id="manageGroups" styleClass="ui-commandlink ui-widget" outcome="manage-groups">
                                                        <h:outputText value="#{bundle['dataverse.option.dataverseGroups']}" />
                                                        <f:param name="dataverseId" value="#{DataversePage.dataverse.id}" />
                                                    </h:link>
                                                </li>
                                            </ui:fragment>
                                            <li>
                                                <h:link id="manageTemplates" styleClass="ui-commandlink ui-widget" outcome="manage-templates">
                                                    <h:outputText value="#{bundle['dataverse.option.datasetTemplates']}" />
                                                    <f:param name="dataverseId" value="#{DataversePage.dataverse.id}" />
                                                </h:link>
                                            </li>
                                            <li jsf:rendered="#{!settingsWrapper.rsyncOnly}">
                                                <h:link id="manageGuestbooks" styleClass="ui-commandlink ui-widget" outcome="manage-guestbooks">
                                                    <h:outputText value="#{bundle['dataverse.option.datasetGuestbooks']}" />
                                                    <f:param name="dataverseId" value="#{DataversePage.dataverse.id}" />
                                                </h:link>
                                            </li>
                                            <li>
                                                <p:commandLink id="browseOpts" actionListener="#{DataversePage.edit('FEATURED')}" oncomplete="PF('browseOptsForm').show()"
                                                               update="dataverseForm:browseOptsForm">
                                                    <h:outputText value="#{bundle['dataverse.option.featuredDataverse']}" />
                                                </p:commandLink>
                                            </li>
                                            <ui:fragment rendered="#{DataversePage.isEmptyDataverse() and !(DataversePage.dataverse.owner == null)
                                                                     and permissionsWrapper.canIssueDeleteDataverseCommand(DataversePage.dataverse)}">
                                                <li class="divider"></li>
                                                <li>
                                                    <p:commandLink id="deleteDataset" onclick="PF('deleteConfirmation').show()">
                                                        <h:outputText value="#{bundle['dataverse.option.deleteDataverse']}" />
                                                    </p:commandLink>
                                                </li>
                                            </ui:fragment>
                                        </ul>
                                    </div>
                                    <!-- END: Edit Button -->
                            </div>

                            <!-- END: Edit/Publish Button Group -->
                            <!-- Email/Link/Share Button Group -->
                            <!--<div class="btn-group pull-right" role="group">
                                <p:commandLink type="button" styleClass="text-button btn-contact bootstrap-button-tooltip" title="#{bundle['dataverse.contact']}"
                                               update=":contactDialog" oncomplete="PF('contactForm').show()" actionListener="#{sendFeedbackDialog.initUserInput}">
                                    <f:setPropertyActionListener target="#{sendFeedbackDialog.userMessage}" value=""/>
                                    <f:setPropertyActionListener target="#{sendFeedbackDialog.userEmail}" value=""/>
                                    <f:setPropertyActionListener target="#{sendFeedbackDialog.messageSubject}" value=""/>
                                    <f:param name="DO_VALIDATION" value="false"/>
                                    <f:setPropertyActionListener target="#{sendFeedbackDialog.recipient}" value="#{DataversePage.dataverse}"/>
                                        <span class="glyphicon glyphicon-envelope"/> #{bundle['contact.contact']}
                                </p:commandLink>
                                <p:commandLink type="button" styleClass="text-button btn-share bootstrap-button-tooltip"
                                   title="#{bundle['dataverse.share.dataverseShare']}"
                                   oncomplete="PF('shareDialog').show();sharrre();">
                                    <span class="glyphicon glyphicon-share"/> #{bundle['share']}
                                </p:commandLink>
                            </div>-->
                            <p:dialog id="shareDialog" header="#{bundle['dataverse.share.dataverseShare']}" widgetVar="shareDialog" modal="true">
                                <p class="help-block">#{bundle['dataverse.share.dataverseShare.tip']}</p>

                                <div id="sharrre-widget" data-url="#{systemConfig.dataverseSiteUrl}/dataverse/#{DataversePage.dataverse.alias}" data-text="#{bundle['dataverse.share.dataverseShare.shareText']}"></div>

                                <div class="button-block">
                                    <button class="btn btn-default" onclick="PF('shareDialog').hide()" type="button">
                                        #{bundle.close}
                                    </button>
                                </div>
                            </p:dialog>
                            <!-- END: Email/Link/Share Button Group -->
                            <!-- Metrics for Root Dataverse -->
                            <div id="metrics-block" class="col-xs-3" jsf:rendered="#{DataversePage.isRootDataverse() and !settingsWrapper.rsyncOnly}">
                                <div id="metrics-label" class="col-xs-4 small text-center">
                                    <h:outputLink value="#{systemConfig.metricsUrl}" target="_blank" title="#{bundle['metrics.title.tip']}" rendered="#{systemConfig.metricsUrl != null}">
                                        <span class="glyphicon glyphicon-stats"/> #{bundle['metrics.title']}
                                    </h:outputLink>
                                    <ui:fragment rendered="#{systemConfig.metricsUrl == null}">
                                        <span class="glyphicon glyphicon-stats"/> #{bundle['metrics.title']}
                                    </ui:fragment>
                                </div>
                                <div id="metrics-content" class="col-xs-8 small text-center">
                                    <h:outputFormat styleClass="metrics-downloads" value="{0} #{bundle['metrics.downloads']}">
                                        <f:param value="#{guestbookResponseServiceBean.getCountOfAllGuestbookResponses()}"/>
                                    </h:outputFormat>
                                </div>
                            </div>
                            <!-- END: Metrics for Root Dataverse-->
                        </div>

                        <ui:fragment rendered="#{SearchIncludeFragment.filterQueries.size() == 0 and SearchIncludeFragment.mode != SearchIncludeFragment.searchModeString}">
                            <o:importFunctions type="edu.harvard.iq.dataverse.util.MarkupChecker" />
                            <ui:fragment rendered="#{!empty DataversePage.dataverse.description and !widgetWrapper.widgetView}">
                                <div id="dataverseDesc" style="margin-bottom:1em;">
                                    <h:outputText value="#{MarkupChecker:sanitizeBasicHTML(DataversePage.dataverse.description)}" escape="false"/>
                                </div>
                                <div class="clearfix"/>
                            </ui:fragment>
                            <!-- Featured Dataverses Carousel -->
                            <div id="carouselBlocksWrapper" jsf:rendered="#{!empty DataversePage.carouselFeaturedDataverses}">
                                <div id="featuredDataversesBlock">
                                    <div class="customNavigation">
                                        <a class="btn prev1" title="#{bundle['dataverse.page.pre']}"><span class="glyphicon glyphicon-chevron-left"/></a>
                                    </div>
                                    <div id="featuredDataversesList" class="owl-carousel owl-theme">
                                        <ui:repeat value="#{DataversePage.carouselFeaturedDataverses}" var="dv" varStatus="status">
                                            <div class="item">
                                                <div style="vertical-align:middle;">
                                                    <c:set var="dvFeatUrl" value="/dataverse/#{dv.alias}"/>
                                                    <a href="#{widgetWrapper.wrapURL(dvFeatUrl)}" title="#{dv.name}">
                                                        <img src="/logos/#{dv.logoOwnerId}/#{dv.dataverseTheme.logo}" alt="#{of:format1(bundle['alt.logo'], dv.name)}" jsf:rendered="#{!empty dv.dataverseTheme.logo}"/>
                                                        <span class="icon-dataverse" jsf:rendered="#{empty dv.dataverseTheme.logo}"></span>
                                                    </a>
                                                    <a href="#{widgetWrapper.wrapURL(dvFeatUrl)}" title="#{dv.name}">
                                                        <h:outputText value="#{dv.name}"/>
                                                    </a>
                                                </div>
                                            </div>
                                        </ui:repeat>
                                    </div>
                                    <div class="customNavigation">
                                        <a class="btn next1" title="#{bundle['dataverse.page.next']}"><span class="glyphicon glyphicon-chevron-right"/></a>
                                    </div>
                                </div>
                            </div>
                            <!-- END: Featured Dataverses Carousel -->
                        </ui:fragment>
                    </ui:fragment>

                    <!-- Save / Cancel Button Panel -->
                    <div class="button-block" jsf:rendered="#{!empty DataversePage.editMode}">
                        <p:commandButton id="save" styleClass="btn btn-default" tabindex="9" value="#{DataversePage.dataverse.id == null ? bundle.createDataverse : bundle.saveChanges}" action="#{DataversePage.save}" update="@all">
                            <f:ajax onerror="window.scrollTo(0, 0)" />
                        </p:commandButton>
                        <!--modify by yqpeng2, bug fixed-->
                        <!--<p:commandButton id="cancel" styleClass="btn btn-link" tabindex="10" value="#{bundle.cancel}" actionListener="#{DataversePage.cancel}" process="@this" update="@form,:searchResults,:messagePanel" rendered="#{DataversePage.dataverse.id != null}" oncomplete="javascript:bind_bsui_components();initCarousel();"/>-->
                        <p:commandButton id="cancel" class="btn btn-link" tabindex="10" value="#{bundle.cancel}" action="#{DataversePage.cancel()}" immediate="true" update="@form,:searchResults,:messagePanel" rendered="#{DataversePage.dataverse.id != null}"/>
                        <p:button id="cancelCreate" styleClass="btn btn-link" tabindex="10" value="#{bundle.cancel}" outcome="/dataverse.xhtml?alias=#{DataversePage.dataverse.owner.alias}" rendered="#{DataversePage.dataverse.id == null and DataversePage.ownerId != null}"/>
                    </div>

                    <!-- POPUPS -->
                    <!-- Featured Dataverses Popup -->
                    <p:dialog id="browseOptsForm" header="#{bundle['dataverse.option.featuredDataverse']}" widgetVar="browseOptsForm" modal="true">
                        <ui:fragment rendered="#{!empty DataversePage.featuredDataverses.source or !empty DataversePage.featuredDataverses.target}">
                            <p:focus for="featuredDataverseList"/>
                            <div class="form-group">
                                <p class="help-block">#{bundle['dataverse.selectToFeature']}</p>
                                <p:pickList id="featuredDataverseList" value="#{DataversePage.featuredDataverses}" var="featureddataverse"
                                            itemLabel="#{featureddataverse.name}"
                                            itemValue="#{featureddataverse}" converter="dataverseConverter"
                                            showSourceFilter="true" showTargetFilter="true" />
                            </div>
                            <div class="button-block">
                                <p:commandButton styleClass="btn btn-default" value="#{bundle.saveChanges}" action="#{DataversePage.save}"/>
                                <button class="btn btn-link" onclick="PF('browseOptsForm').hide();" type="button">                              
                                    #{bundle.cancel}
                                </button>
                            </div>
                        </ui:fragment>
                        <ui:fragment rendered="#{empty DataversePage.featuredDataverses.source and empty DataversePage.featuredDataverses.target}">
                            <p class="text-danger">
                                <span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataverse.nopublished.tip']}
                            </p>
                            <div class="button-block">
                                <button class="btn btn-default" onclick="PF('browseOptsForm').hide();" type="button">                              
                                    #{bundle.close}
                                </button>
                            </div>
                        </ui:fragment>
                    </p:dialog>

                    <!-- Publish Confirmation Popup -->
                    <p:dialog id="publishDvConfirm" header="#{bundle['dataverse.publish.header']}" widgetVar="confirmation" modal="true">
                        <p class="text-warning">
                            <span class="glyphicon glyphicon-warning-sign"/> #{bundle['dataverse.publish.tip']}
                        </p>
                        <div class="button-block">
                            <p:commandButton styleClass="btn btn-default" value="#{bundle.continue}" onclick="PF('confirmation').hide()" action="#{DataversePage.releaseDataverse}"/>
                            <button class="btn btn-link" onclick="PF('confirmation').hide();" type="button">                              
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>

                    <p:dialog id="mayNotRelease" header="#{bundle['dataverse.publish.header']}" widgetVar="mayNotRelease" modal="true">
                        <p class="text-danger">
                            <span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataverse.publish.failed.tip']}
                        </p>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('mayNotRelease').hide();" type="button">                              
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>

                    <p:dialog id="deleteDvConfirm" header="#{bundle['dataverse.delete']}" widgetVar="deleteConfirmation" modal="true">
                        <p class="text-warning">
                            <span class="glyphicon glyphicon-warning-sign"/> #{bundle['dataverse.delete.tip']}
                        </p>
                        <div class="button-block">
                            <p:commandButton styleClass="btn btn-default" value="#{bundle.continue}" onclick="PF('deleteConfirmation').hide()" action="#{DataversePage.deleteDataverse}"/>
                            <button class="btn btn-link" onclick="PF('deleteConfirmation').hide();" type="button">                              
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>
                </h:form>

                <!-- Search/Browse Facets Panel -->
                <p:fragment id="searchResults">
                    <ui:fragment rendered="#{empty DataversePage.editMode}">
                        <ui:include src="search-include-fragment.xhtml"/>
                    </ui:fragment>
                </p:fragment>

                <!-- Link Dataverse Popup -->
                <p:dialog id="linkDataverseForm" header="#{DataversePage.linkMode == 'SAVEDSEARCH' ? bundle['dataverse.savedsearch.link'] : bundle['dataverse.link']}" widgetVar="linkDataverseForm" modal="true">
                    <h:form styleClass="form-horizontal" rendered="#{DataversePage.dataversesForLinking.size() > 1}">
                        <p:focus for="dvNameSelect"/>
                        <ui:fragment rendered="#{DataversePage.linkMode == 'LINKDATAVERSE'}">
                            <p class="help-block">#{bundle['dataverse.link.dataverse.choose']}</p>
                        </ui:fragment>
                        <ui:fragment rendered="#{DataversePage.linkMode == 'SAVEDSEARCH'}">
                            <p class="help-block">#{bundle['dataverse.savedsearch.dataverse.choose']}</p>
                        </ui:fragment>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">
                                <h:outputFormat value="#{bundle['dataverse.link.yourDataverses']}">
                                    <f:param value="#{DataversePage.dataversesForLinking.size()}"/>
                                </h:outputFormat>
                            </label>
                            <div class="col-sm-7">
                                <h:selectOneMenu id="dvNameSelect" styleClass="form-control" value="#{DataversePage.linkingDataverseId}">
                                    <f:selectItems value="#{DataversePage.linkingDVSelectItems}" />
                                </h:selectOneMenu>
                                <ui:remove>
                                <p:autoComplete id="dvName"
                                                value="#{DataversePage.dataversesForLinking}"
                                                queryDelay="1000"
                                                var="u"
                                                itemLabel="#{u.id}"
                                                itemValue="#{u.id}">
                                    <f:facet name="itemtip">
                                        <div>
                                            <strong>#{u.id}</strong><br/>
                                            <em>#{u.affiliation}</em>

                                        </div>
                                    </f:facet>
                                </p:autoComplete>
                                </ui:remove>
                            </div>
                        </div>
                        <ui:fragment rendered="#{DataversePage.linkMode == 'SAVEDSEARCH'}">
                            <div class="form-group" jsf:rendered="#{!empty SearchIncludeFragment.query}">
                                <label class="col-sm-4 control-label">
                                     #{bundle['dataverse.savedsearch.searchquery']}
                                </label>
                                <div class="col-sm-7">
                                    <p class="form-control-static">
                                        #{SearchIncludeFragment.query}
                                    </p>
                                </div>
                            </div>
                            <div class="form-group" jsf:rendered="#{!empty SearchIncludeFragment.filterQueriesDebug}">
                                <label class="col-sm-4 control-label">
                                     #{bundle['dataverse.savedsearch.filterQueries']}
                                </label>
                                <div class="col-sm-7">
                                    <ui:repeat value="#{SearchIncludeFragment.filterQueriesDebug}" var="fq">
                                        <p class="form-control-static"><h:outputText value="#{fq}"/></p>
                                    </ui:repeat>
                                </div>
                            </div>
                        </ui:fragment>
                        <div class="button-block">
                            <p:commandButton styleClass="btn btn-default" value="#{bundle['dataverse.link.save']}" action="#{DataversePage.saveLinkedDataverse}"
                                              rendered="#{DataversePage.linkMode == 'LINKDATAVERSE'}"/>
                            <p:commandButton styleClass="btn btn-default" value="#{bundle['dataverse.savedsearch.save']}" action="#{DataversePage.saveSavedSearch}"
                                             rendered="#{DataversePage.linkMode == 'SAVEDSEARCH'}"/>
                            <button class="btn btn-link" onclick="PF('linkDataverseForm').hide();" type="button">                              
                                #{bundle.cancel}
                            </button>
                        </div>
                    </h:form>
                    <ui:fragment rendered="#{DataversePage.dataversesForLinking.size() == 1}">
                        <p class="help-block">#{bundle['dataverse.link.no.choice']}</p>
                        <div class="form-horizontal">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">
                                    <h:outputFormat value="#{bundle['dataverse.link.yourDataverses']}">
                                        <f:param value="#{DataversePage.dataversesForLinking.size()}"/>
                                    </h:outputFormat>
                                </label>
                                <div class="col-sm-7">
                                    <p class="form-control-static">#{DataversePage.linkingDataverse.displayName}</p>
                                </div>
                            </div>
                        </div>
                        <div class="button-block">
                            <p:commandButton styleClass="btn btn-default" value="#{bundle['dataverse.link.save']}" onclick="PF('linkDataverseForm').hide()" actionListener="#{DataversePage.saveLinkedDataverse()}"/>
                            <button class="btn btn-link" onclick="PF('linkDataverseForm').hide();" type="button">                              
                                #{bundle.cancel}
                            </button>
                        </div>
                    </ui:fragment>
                    <ui:fragment rendered="#{DataversePage.dataversesForLinking.size() == 0}">
                        <p class="text-danger">
                            <span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataverse.link.no.linkable']}
                        </p>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('linkDataverseForm').hide();" type="button">                              
                                #{bundle.close}
                            </button>
                        </div>
                    </ui:fragment>
                </p:dialog>

                <!-- Metadata Resest Modifications Popup -->
                <p:dialog id="resetModifications" header="#{bundle['dataverse.resetModifications']}" widgetVar="resetModifications" modal="true" closable="false">
                    <p class="text-warning">
                        <span class="glyphicon glyphicon-warning-sign"/> #{bundle['dataverse.resetModifications.text']}
                    </p>
                    <div class="button-block">
                        <p:commandButton styleClass="btn btn-default" value="#{bundle.continue}" onclick="check();PF('resetModifications').hide()"/>
                        <button class="btn btn-link" onclick="uncheck();PF('resetModifications').hide()" type="button">                              
                            #{bundle.cancel}
                        </button>
                    </div>
                </p:dialog>

                <script>
                    //<![CDATA[
                    var scrollPos=0;

                    $(document).ready(function () {
                        initCarousel();
                        popoverHTML('#{bundle.htmlAllowedTitle}');
                    });

                    function initCarousel() {
                        var owl1 = $("#featuredDataversesList");

                        owl1.owlCarousel({
                            pagination: false,
                            navigation: false,
                            items: 4, //10 items above 1000px browser width
                            itemsDesktop: [1140, 4], //5 items between 1000px and 901px
                            itemsDesktopSmall: [940, 3], // betweem 900px and 601px
                            itemsTablet: [720, 2], //2 items between 600 and 0
                            itemsMobile: false // itemsMobile disabled - inherit from itemsTablet option
                        });
                        if (owl1.find('div.owl-item').length > 4) {
                            // Custom Navigation Events
                            $(".next1").click(function () {
                                owl1.trigger('owl.next');
                            });
                            $(".prev1").click(function () {
                                owl1.trigger('owl.prev');
                            });
                        } else {
                            $("#featuredDataversesBlock .customNavigation a.btn").hide();
                        }
                        $('#featuredDataversesList .item').matchHeight();
                    }

                    function callOnError(){
                        alert("in js");
                        window.scrollTo(0, 0);
                    }

                    function updateInclude() {
                        $('button[id$="hiddenRefresh"]').trigger('click');
                    }
                    
                    function scrollAfterUpdate() {
                        document.getElementById('metadataFieldOptionsPanel-Body').scrollTop = scrollPos;
                    }

                    function updateMetadata(checkbox) {
                        var checked = checkbox.checked;
                        if (checked === false){
                            $('button[id$="updateMetadataButton"]').trigger('click');
                        } else {
                            PF('resetModifications').show();
                        }
                    }

                    function check() {
                        $('button[id$="resetToInherit"]').trigger('click');
                    }

                    function uncheck() {
                        $('input:checkbox[id$="metadataRoot"]').prop('checked', false);
                    }

                    function collAllOptions(){
                        const $optionsPanel = $('#metadataFieldOptionsPanel-Block input[type="radio"]:checked');
                        if($optionsPanel.length>0){
                            const radioCollObjTemp = {};
                            $optionsPanel.each(function(i,v){
                                const $table = $(this).closest("table");
                                const $dsfId = $table.next();
                                const dsfId = $dsfId.val();
                                const rvalue = $(this).val();
                                radioCollObjTemp[dsfId] = rvalue;
                            });
                            var datasetFieldType = JSON.stringify(radioCollObjTemp);
                            $('input[id$="datasetFieldTypeJson"]').val(datasetFieldType);
                        }
                    }
                    //]]>
                </script>

            </ui:define>
        </ui:composition>
    </h:body>
</html>
